 package fun.codedesign.eclipse.jdt;

 import org.eclipse.jdt.core.dom.ASTParser;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.junit.jupiter.api.Test;

 /**
  * EclipseASTParserTest <br>
  *
  * @author zengjian
  * @create 2018/11/20 13:08
  * @since 1.0.0
  */
 public class ReadJavaCode {

     static String source = CodeExample.EXAMPLE1;

     @Test
     public void parseSourceCode() {
         ASTParser astParser = ASTParser.newParser(11);
         // 生成编译单元
         astParser.setKind(ASTParser.K_COMPILATION_UNIT);
         // TODO
         astParser.setSource(source.toCharArray());
         astParser.setResolveBindings(true);
         CompilationUnit compilationUnit = (CompilationUnit) astParser.createAST(null);
         System.out.println(compilationUnit.toString());
     }
 }